﻿<?xml version="1.0" encoding="utf-8" ?>
<DbDataRequest connection="$DBConnection$" type="$ForumDBType$" defaultFormatter="bizobj ApprovalData(approvalSet(approvers),approvalDataChange)">
	<SqlStatement hasResults="true">
		SELECT
			ApprovalData.ID AS ApprovalDataid
			,ApprovalData.originalAction AS ApprovalDataOriginalAction
			,ApprovalData.state AS ApprovalDatastate
			,ApprovalData.nextApprover as ApprovalDatanextApprover
			,ApprovalData.objectId as ApprovalDataobjectId
			,ApprovalDataChange.id as ApprovalDataChangeid
			,ApprovalDataChange.bizObjData as ApprovalDataChangebizObjData
			,ApprovalDataChange.actionType as ApprovalDataChangeactionType
			,ApprovalSet.id as ApprovalSetid
			,ApprovalSet.objectType as ApprovalSetobjectType
			,ApprovalSet.saveHistory as ApprovalSetsaveHistory
			,ApprovalSet.moveToParent as ApprovalSetmoveToParent
			,ApprovalSet.parentId as ApprovalSetparentId
			,ApprovalSetApprovers.id as Approversid
			,ApprovalSetApprovers.approverId as ApprovalSetApproversapproverid
		FROM ApprovalData INNER JOIN ApprovalDataChange
			  ON ApprovalData.id= ApprovalDataChange.ApprovalDataId
					   INNER JOIN ApprovalSet ON ApprovalData.ApprovalSetId=ApprovalSet.id
									  INNER JOIN ApprovalSetApprovers ON ApprovalSet.id = ApprovalSetApprovers.approvalSetId
		WHERE ApprovalSet.ObjectType=@typeName
			  AND ApprovalSet.ParentId = ApprovalData.objectId 
					   AND ApprovalData.state=0
	</SqlStatement>
	<Param name="typeName" type="UnicodeVarChar" />
</DbDataRequest >
